package org.example.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;

@Component
public class ScheduledTask {

    @Autowired
    private TimeTask timeTask;

    @Autowired
    private Executor taskExecutor;

    /**
     * 启动倒计时任务
     */
    @Async("taskExecutor")
    public void startCountdownTask() {
        taskExecutor.execute(() -> timeTask.countdown(60)); // 倒计时60秒
    }
}
